-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(theme-toggle): resolve hydration error and add to Projects page #680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(theme-toggle): resolve hydration error and add to Projects page #680
Conversation
- Fix OpenCut-app#648: Add mounted state to prevent hydration mismatch - Fix OpenCut-app#648: Use resolvedTheme to correctly detect dark/light mode - Fix OpenCut-app#648: Display Sun icon in dark mode, Moon icon in light mode - Fix OpenCut-app#646: Add ThemeToggle component to Projects page header
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
|
@ThanhNguyxn is attempting to deploy a commit to the OpenCut OSS Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds a client-mounted ThemeToggle to prevent SSR hydration mismatches and updates the Projects page header to render ThemeToggle when not in selection mode. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/web/src/components/theme-toggle.tsx`:
- Around line 22-26: The Button elements in theme-toggle.tsx currently lack an
explicit type, which can cause accidental form submission; update both Button
usages (the one returning the icon span and the one in the alternate block at
lines referenced) to include type="button" on the <Button> components so they do
not act as default submit buttons when placed inside a form.
Summary
This PR fixes two related issues with the ThemeToggle component:
Fixes #648 - ThemeToggle hydration error and wrong icon display
Problem:
useTheme()returnsundefinedon the serverSolution:
mountedstate to prevent hydration mismatch between server and clientresolvedThemeinstead ofthemeto correctly detect the actual theme (handles "system" theme)classNameprop not being appliedFixes #646 - Add theme toggle to Projects page
Problem:
Solution:
Changes
apps/web/src/components/theme-toggle.tsx: Fixed hydration error and icon logicapps/web/src/app/projects/page.tsx: Added ThemeToggle import and componentTesting
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.